#!/usr/bin/env node
import { Radio } from './06-radio.js';

// 定义一个 station 对象
const station = {
  freq: '89.3',
  name: 'Classical Music Radio'
};

// 实例化 Radio 对象
const radio = new Radio(station);

// 处理 Radio 对象的 play 事件
radio.on('play', (station) => {
  console.log(`Radio is playing on station ${station.name} at frequency ${station.freq}.`);
});

// 处理 Radio 对象的 stop 事件
radio.on('stop', (station) => {
  console.log(`Radio has stopped playing on station ${station.name}.`);
});

// 测试程序
console.log('Radio test started...');
radio.play(); // 这将自动 call radio.stop() after 5 seconds